﻿using M_Quality.API.Application.Command.QualityPlanCommand;
using M_Quality.Repository.Interface;
using MediatR;

namespace M_Quality.API.Application.CommandHandler.QualityPlanCommandHandler
{
    /// <summary>
    ///修改质检方案状态
    /// </summary>
    public class QualityPianUpdateSarteCommandHandler : IRequestHandler<QualityPianUpdateSarteCommand, int>
    {
        protected readonly IQualityPlanRepositry _qualityPlanRepositry;

        public QualityPianUpdateSarteCommandHandler(IQualityPlanRepositry qualityPlanRepositry)
        {
            _qualityPlanRepositry = qualityPlanRepositry;
        }
        public async Task<int> Handle(QualityPianUpdateSarteCommand request, CancellationToken cancellationToken)
        {
            var upSarte = await _qualityPlanRepositry.GetModelAsync(request.QualityPlanId);
            upSarte.QualityPlanSart=request.QualityPlanSart;
            return await _qualityPlanRepositry.UpdateAsync(upSarte);
            
        }
       
    }
}
